
 /**
  ********************************************
  HomeWork3
  ********************************************
  
 * This program uses "LinkedList" in conjunction with "node" to complete Homework 3
 * 
 * The following are tests to ensure that it works correctly.
 * The LinkedList and Node classes can be used independently of these tests
 * 
 * @author (Greg Shevach & Chris Nerf) 
 * @version (v1.01)
 * @date (9/27/11)
 */
         

public class HomeWork3
{
	public static void main(String [] args)
	{
		LinkedList ll = new LinkedList();
		
		
		//test .isEmpty()
		//should return true, as there is no elements yet in the list
		try
		{
			System.out.println("Is the linked list empty? (true is success): ");
			System.out.println(ll.isEmpty());
		}
		catch (Exception wtf)
		{
			System.out.println(wtf.toString());
			wtf.printStackTrace();
		}
		finally
		{
			System.out.println("End isEmpty()'s positive test\n_______________________________");
		}
		
		//test linked list throwing errors for empty list
		//.front() test
		try
		{
			System.out.println("Getting from the front should fail, there should be an error message stating the linked list was empty: ");
			ll.front();
			System.out.println("IF THIS PRINTS SOMETHING WENT WRONG.");
		}
		catch (java.lang.RuntimeException wtf)
		{
			System.out.println(wtf.toString());
			
		}
		catch (Exception wtf)
		{
			wtf.printStackTrace();
		}
		finally
		{
			System.out.println("End .front() test\n_______________________________");
		}
		
		
		//.removeFront() test
		try
		{
		System.out.println("Attempting to remove from the front should fail, there should be an error message stating the linked list was empty: ");
		ll.removeFront();
		System.out.println("IF THIS PRINTS SOMETHING WENT WRONG.");
		}
		catch (java.lang.RuntimeException wtf)
		{
			System.out.println(wtf.toString());
		}
		finally
		{
			System.out.println("End .removeFront() test\n_______________________________");
		}
		
		
		//Time to add our first element
		//.addRear(T) test
		//using string because it's easy
		try
		{
			ll.addRear("Hello,");
			System.out.println("All's well with addRear()");
		}
		catch (Exception wtf)
		{
			System.out.println(wtf.toString());
			wtf.printStackTrace();
		}
		finally
		{
			System.out.println("End .addRear() test\n_______________________________");
		}
		
		//Time to test .front() positively
		try
		{
			System.out.println("Getting front element should succeed: ");
			System.out.println(ll.front());
			System.out.println("All is well with the front element.");
		}
		catch (java.lang.RuntimeException wtf)
		{
			System.out.println(wtf.toString());
		}
		finally
		{
			System.out.println("End .front() success test\n_______________________________");
		}
		
		
		//test isEmpty() for a negative response
		try
		{
			System.out.println("Is the linked list empty? (false is success): ");
			System.out.println(ll.isEmpty());
		}
		catch (Exception wtf)
		{
			System.out.println(wtf.toString());
			wtf.printStackTrace();
		}
		finally
		{
			System.out.println("End isEmpty()'s negative test\n_______________________________");
		}
		
		//test toString(), it should print each element in the array, space delimited
		try
		{
			System.out.println("The following should read \"Hello,\":");
			System.out.println(ll.toString());
		}
		catch (Exception wtf)
		{
			System.out.println(wtf.toString());
			wtf.printStackTrace();
		}
		finally
		{
			System.out.println("End toString() single element test\n_______________________________");
		}

		//add many more objects to the linked list
		try
		{
			ll.addRear("my");
			ll.addRear("name");
			ll.addRear("is");
			ll.addRear("Inigo");
			ll.addRear("Montoya");
		}
		catch (Exception wtf)
		{
			System.out.println(wtf.toString());
			wtf.printStackTrace();
		}
		
		//Print multiple elements with toString(), as above
		try
		{
			System.out.println("The following should read \"Hello, my name is Inigo Montoya\":");
			System.out.println(ll.toString());
			
		}
		catch (Exception wtf)
		{
			System.out.println(wtf.toString());
			wtf.printStackTrace();
		}
		finally
		{
			System.out.println("End toString() multiple element test\n_______________________________");
		}
		
		//Time to removeFront()
		//.removeFront() test
		try
		{
			System.out.println("Attempting to remove front, should remove \"Hello,\": ");
			System.out.println(ll.removeFront());
			//Print multiple elements with toString()
			System.out.println("The following print out should read: \"my name is Inigo Montoya\"");
			System.out.println(ll.toString());
			//TODO fix the error below
			/*
			 * Attempting to remove front: 
			 *	The following print out should read: "my name is Inigo Montoya"
			 *	java.lang.NullPointerException
			 *	End .removeFront() test
			 *	FIXED
			 *
			 */
			
		}
		catch (java.lang.NullPointerException wtf)
		{
			System.out.println(wtf.toString());
			wtf.printStackTrace();
		}
		catch (Exception wtf)
		{
			System.out.println(wtf.toString());
			
		}
		finally
		{
			System.out.println("End .removeFront() test\n_______________________________");
		}	
		
		
		
	}

}
